home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 9.4 KB | 315 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPrtIte.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- // ----- ODUtil -----
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODFacetIterator_xh
- #include <FacetItr.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include <FrFaItr.xh>
- #endif
-
- //========================================================================================
- // Runtime informations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment framework
- #endif
-
- //========================================================================================
- // class FW_CPartFrameIterator
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::FW_CPartFrameIterator
- //---------------------------------------------------------------------------------------
-
- FW_CPartFrameIterator::FW_CPartFrameIterator(const FW_CPart* part) :
- fPresentationIterator(NULL),
- fFrameIterator(NULL),
- fCurrentFrame(NULL)
- {
- fPresentationIterator = FW_NEW(FW_CPartPresentationIterator, (part));
- FW_END_CONSTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::~FW_CPartFrameIterator
- //---------------------------------------------------------------------------------------
-
- FW_CPartFrameIterator::~FW_CPartFrameIterator()
- {
- FW_START_DESTRUCTOR
-
- delete fPresentationIterator;
- fPresentationIterator = NULL;
-
- delete fFrameIterator;
- fFrameIterator = NULL;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::First
- //---------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CPartFrameIterator::First()
- {
- FW_CPresentation* presentation = fPresentationIterator->First();
- PrivFirstFrame(presentation);
-
- return fCurrentFrame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::Last
- //---------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CPartFrameIterator::Last()
- {
- FW_CPresentation* presentation = fPresentationIterator->Last();
- PrivLastFrame(presentation);
-
- return fCurrentFrame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::Next
- //---------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CPartFrameIterator::Next()
- {
- FW_ASSERT(fFrameIterator);
-
- fCurrentFrame = fFrameIterator->Next();
- if (fCurrentFrame == NULL)
- {
- FW_CPresentation* presentation = fPresentationIterator->Next();
- PrivFirstFrame(presentation);
- }
-
- return fCurrentFrame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::Previous
- //---------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CPartFrameIterator::Previous()
- {
- FW_ASSERT(fFrameIterator);
-
- fCurrentFrame = fFrameIterator->Previous();
- if (fCurrentFrame == NULL)
- {
- FW_CPresentation* presentation = fPresentationIterator->Previous();
- PrivLastFrame(presentation);
- }
-
- return fCurrentFrame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::PrivFirstFrame
- //---------------------------------------------------------------------------------------
-
- void FW_CPartFrameIterator::PrivFirstFrame(FW_CPresentation* presentation)
- {
- fCurrentFrame = NULL;
-
- delete fFrameIterator;
- fFrameIterator = NULL;
-
- while (presentation != NULL)
- {
- fFrameIterator = FW_NEW(FW_CPresentationFrameIterator, (presentation));
- fCurrentFrame = fFrameIterator->First();
- if (fCurrentFrame != NULL)
- return;
-
- delete fFrameIterator;
- fFrameIterator = NULL;
- presentation = fPresentationIterator->Next();
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartFrameIterator::PrivLastFrame
- //---------------------------------------------------------------------------------------
-
- void FW_CPartFrameIterator::PrivLastFrame(FW_CPresentation* presentation)
- {
- fCurrentFrame = NULL;
-
- delete fFrameIterator;
- fFrameIterator = NULL;
-
- while (presentation != NULL)
- {
- fFrameIterator = FW_NEW(FW_CPresentationFrameIterator, (presentation));
- fCurrentFrame = fFrameIterator->Last();
- if (fCurrentFrame != NULL)
- return;
-
- delete fFrameIterator;
- fFrameIterator = NULL;
- presentation = fPresentationIterator->Previous();
- }
- }
-
- //========================================================================================
- // class FW_CPartPresentationIterator
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CPartPresentationIterator::FW_CPartPresentationIterator
- //---------------------------------------------------------------------------------------
-
- FW_CPartPresentationIterator::FW_CPartPresentationIterator(const FW_CPart* part) :
- fIterator(NULL)
- {
- fIterator = new FW_COrderedCollectionIterator(part->fPresentations);
- FW_END_CONSTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPartPresentationIterator::~FW_CPartPresentationIterator
- //---------------------------------------------------------------------------------------
-
- FW_CPartPresentationIterator::~FW_CPartPresentationIterator()
- {
- FW_START_DESTRUCTOR
-
- delete fIterator;
- fIterator = NULL;
- }
-
- //========================================================================================
- // FW_CPartProxyFrameIterator
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPartProxyFrameIterator::FW_CPartProxyFrameIterator
- //----------------------------------------------------------------------------------------
-
- FW_CPartProxyFrameIterator::FW_CPartProxyFrameIterator(const FW_CEmbeddingPart* part):
- fIterator(NULL)
- {
- fIterator = new FW_COrderedCollectionIterator(part->fProxyFrames);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CProxyProxyFrameIterator::~FW_CProxyProxyFrameIterator
- //----------------------------------------------------------------------------------------
-
- FW_CPartProxyFrameIterator::~FW_CPartProxyFrameIterator()
- {
- FW_START_DESTRUCTOR
- delete fIterator;
- }
-
- //========================================================================================
- // FW_CPartEmbeddedFrameIterator
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPartEmbeddedFrameIterator::FW_CPartEmbeddedFrameIterator
- //----------------------------------------------------------------------------------------
-
- FW_CPartEmbeddedFrameIterator::FW_CPartEmbeddedFrameIterator(Environment* ev, const FW_CEmbeddingPart* part, FW_CEmbeddingFrame* frame) :
- fIterator(part),
- fCurrentFrame(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPartEmbeddedFrameIterator::~FW_CPartEmbeddedFrameIterator
- //----------------------------------------------------------------------------------------
-
- FW_CPartEmbeddedFrameIterator::~FW_CPartEmbeddedFrameIterator()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPartEmbeddedFrameIterator::First
- //----------------------------------------------------------------------------------------
-
- ODFrame* FW_CPartEmbeddedFrameIterator::First(Environment* ev)
- {
- FW_CProxyFrame* proxyFrame = fIterator.First();
- fCurrentFrame = PrivNext(ev, proxyFrame);
- return fCurrentFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPartEmbeddedFrameIterator::Next
- //----------------------------------------------------------------------------------------
-
- ODFrame* FW_CPartEmbeddedFrameIterator::Next(Environment* ev)
- {
- FW_CProxyFrame* proxyFrame = fIterator.Next();
- fCurrentFrame = PrivNext(ev, proxyFrame);
- return fCurrentFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPartEmbeddedFrameIterator::PrivNext
- //----------------------------------------------------------------------------------------
-
- ODFrame* FW_CPartEmbeddedFrameIterator::PrivNext(Environment* ev, FW_CProxyFrame* proxyFrame)
- {
- while (proxyFrame != NULL)
- {
- if (proxyFrame->IsFrameInMemory(ev))
- return proxyFrame->GetFrame(ev);
-
- proxyFrame = fIterator.Next();
- }
-
- return NULL;
- }
-
-